<template>
	<view>
		<view class="btns iceFlexAd">
			<view class="iceFlexSt" @click="changeQ(-1)">
				<u-icon name="arrow-left" color="#999" size="16" v-if="props.changeQ != 0"></u-icon>
				<text class="time" v-if="props.changeQ != 0">上一题</text>
			</view>
			<view v-if="props.changeQ != props.questionInfoData[1] - 1" class="iceFlexSt" @click="changeQ(1)">
				<text class="time">下一题</text>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
			<view v-else class="iceFlexSt" @click="emits('submit')">
				<text class="time">交卷</text>
				<u-icon name="arrow-right" color="#999" size="16"></u-icon>
			</view>
		</view>
		<iceMessage :msgParams="msgParams.value" @iceClose="msgParams.isOpen=false" />
	</view>
</template>

<script setup>
	import {
		ref,reactive
	} from 'vue'
	import {
		GLOBAL_TYPE
	} from '../../utils/dict';
	const emits = defineEmits(['changeQ','submit'])
	const props = defineProps({
		questionInfoData: {
			type: Array
		},
		changeQ:{
			type:Number
		}
	})
	const msgParams = reactive({
		value: {}
	})
	const changeQ = (step) => {
		if ((step == -1 && props.changeQ != 0) || (step == 1 && props.changeQ != props.questionInfoData[1] - 1)) {
			const newQ = props.changeQ + step
			emits('changeQ',newQ)
		} else {
			msgParams.value = {
				msgType: 'e',
				messageText: step == -1 ? '已经是第一题了' : '已经是最后一题了',
				isOpen: true
			}
		}
	}
</script>

<style lang="scss" scoped>
	.btns {
		width: 100%;
		height: 120px;
		// padding: 10px 0;
		box-shadow: 1px -2px 5px #999;
		color: #999;

		view {
			width: 20%;
			text-align: center;
			height: 120px;
			// background-color: red;
			color: #999;
			line-height: 120px;
		}
	}
</style>